<template>
    <div class="add_Alipay">
        <div class="Alipay">
            <input type="text" v-model="Alipay_num" placeholder="请输入支付宝账号">
            <input type="text" v-model="Alipay_name" placeholder="请输入支付宝认证姓名">
            <div class="btn">
                <button @click="update_alipay()">提交</button>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        name: 'addAlipay',
        data() {
            return {
                Alipay_num: '',
                Alipay_name: '',
            }
        },
        methods: {
            update_alipay() { // 添加支付宝账号
                if(this.Alipay_num.replace(/(^\s*)|(\s*$)/g, "") == '') return this.$vux.toast.text('请填写支付宝账号')
                if(this.Alipay_name.replace(/(^\s*)|(\s*$)/g, "") == '') return this.$vux.toast.text('请填写支付宝认证姓名')
                let params = {
                    targetType: this.$route.query.type,
                    userId: this.$store.state.userId,
                    alipayID: this.Alipay_num,
                    alipayname: this.Alipay_name,
                }
                this.$http.fetchPost('update_alipay', params).then(res => {
                    if(res.code == 200) {
                        this.$vux.toast.text('添加成功')
                        this.$router.back(-1)
                    } else {
                        this.$vux.toast.text('添加失败')
                    }
                }, err =>{

                })
            }
        },
        mounted() {

        }
    }
</script>

<style lang="less" scoped>
    .add_Alipay{
        position: absolute;
        top:0;
        bottom: 0;
        width: 100%;
        .Alipay{
            .mt(20);
            input{
                display: block;
                width: 100%;
                .h(88);
                border:none;
                border-bottom: 1px solid #f2f2f2;
                .padd(0, 20);
                box-sizing: border-box;
                outline:none;
            }
            .btn{
                width: 100%;
                .padd(0, 20);
                .mt(50);
                box-sizing: border-box;
                button{
                    display: block;
                    width: 100%;
                    .h(88);
                    border: none;
                    border-radius: 5px;
                    color: #fff;
                    background: #189BEB;
                    outline:none;
                }
            }
        }
    }
</style>
